public class Person {
    String name;
    char gender;
    int age;
    boolean married;
    Person(String name,char gender,int age,boolean married){
        this.name=name;
        this.gender=gender;
        this.age=age;
        this.married=married;
    }
    public void marry( Person another ) {   
        if(this.married==false && another.married==false){
            if(this.gender!=another.gender){
                if(this.gender=='男' &&  this.age>=22){
                    if(another.age>=20){
                        System.out.println(this.name+"和"+another.name+"结婚");
                    }
                    else{
                        System.out.println("女方未达到年龄！");
                    }
                }
                else if(this.gender=='女' &&  this.age>=20){
                    if(another.age>=22){
                        System.out.println(this.name+"和"+another.name+"结婚");
                    }
                    else{
                        System.out.println("男方未达到年龄！");
                    }
                }
            }
            else{
                System.out.println("同性不能结婚！");
            }
            }
        else{
            System.out.println("已经结婚的人不能结婚！");
        }
     }
    public static void main(String[] args) {
        Person p1=new Person("小一",'女',23,false);
        Person p2=new Person("赵二",'男',20,false);
        Person p3=new Person("张三",'男',23,false);
        Person p4=new Person("隔壁老王",'男',23,true);
        Person p5=new Person("李四",'男',23,false);
        p1.marry(p2);
        p1.marry(p3);
        p1.marry(p4);
        p3.marry(p5);
    }
}